package com.longge;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-06-06 01:56
 */
public class SelfDividingNumbers {

    public List<Integer> selfDividingNumbers(int left, int right) {

        ArrayList<Integer> res = new ArrayList<>();
        for (int i = left; i <= right; i++) {
            int temp = i;
            while (temp != 0) {
                int divisor = temp % 10;
                if (divisor == 0 || i % divisor != 0) break;
                temp /= 10;
            }
            if (temp == 0) res.add(i);

        }
        return res;
    }

    public static void main(String[] args) {
        new SelfDividingNumbers().selfDividingNumbers(1, 22);
    }
}
